<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.io.*" %>
<%@ page import="jsp.util.ConnectionContext" %>
<%@ page import="java.sql.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Main</title>
 <link rel=stylesheet href="form.css" type="text/css">
</head>

<body>

<div id="wrapper" style="border:1px solid #696">
	<jsp:include page="Menubar.jsp" flush="false"/>
	
<center>
<p></p> 
<font size='3'><b> Notice </b></font>
<p></p>             
</center>

<TABLE border="0" width="600" cellpadding="2" cellspacing="2" align="center">
	<TR>
      		<TD>
         		<hr size='1' noshade>
      		</TD>
	</TR>
</TABLE>


 
<%
    request.setCharacterEncoding("utf-8");
	 
	
	String Prof_number=request.getParameter("hiddenvalue");
	String title=request.getParameter("title");
	String name=request.getParameter("prof_Name");
	String content=request.getParameter("content");
	String numbering=request.getParameter("hiddennumber");
	int count=0;
	
	try{
		Connection conn = ConnectionContext.getConnection();
		PreparedStatement pstmt = conn.prepareStatement("INSERT INTO profnotice(profName, profNum, title, registerDate, count, content, numbering)"+ " values (?,?,?,now(),?,?,?)");				
		pstmt.setString(1, name);
		pstmt.setString(2, Prof_number);
		pstmt.setString(3, title);
		pstmt.setInt(4, 0);
		pstmt.setString(5, content);
		pstmt.setString(6, numbering);
		pstmt.executeUpdate();
	}catch(SQLException ex){
%>
	에러: <%=ex %>
<%

	}
	Connection conn = ConnectionContext.getConnection();
	PreparedStatement pstmt = conn.prepareStatement("select * from profnotice where numbering=?");
	pstmt.setString(1, numbering);
	ResultSet rs = pstmt.executeQuery(); 
	
	while(rs.next()){
	

%>

<TABLE border="0" width="600" cellpadding="2" cellspacing="2" align="center">
<tr>
    <TD width="100" bgcolor="cccccc" align=center><font size="2">Title</font></td>
    <td colspan="3"><%=rs.getString("title")%></td>
</tr>
<tr>
    <TD width="100" bgcolor="cccccc" align=center><font size="2">Writer</font></td>
    <td width="200"><%=rs.getString("profName")%></td>
	<TD width="100" bgcolor="cccccc" align=center><font size="2">교수님번호</font></td>
	<td width="200"><%=Prof_number%></td>
</tr>
<tr>
    <TD width="100" bgcolor="cccccc" align=center><font size="2">Date</font></td>
    <td><%=rs.getDate("registerDate")%></td>
    <TD width="100" bgcolor="cccccc" align=center><font size="2">Count</font></td>
    <td><%=count%></td>
</tr>
<tr>    	
    <TD width="100" bgcolor="cccccc" align=center><font size="2">Content</font></td>
    <td colspan="4"><textarea cols='70' rows='15' name='contents' ><%=rs.getString("content")%></textarea></td>
</tr>
</table>
<%
}
%>

<script language="javascript">
	function buttonclick(){
		
		history.go(-2);
		location.reload();
		
	}

</script>

<center>
	<a href="QandA.jsp"><input type="button" value="목록" onclick="buttonclick()"></a>
</center>

	</div>
</body>
</html>

